package com.wangp.springbootsource.ioc.ann;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * <pre>
 * classname MyBeanPostProcessor
 * description
 * </pre>
 *
 * @author wangp
 * @date 2020/9/19 11:39
 **/
@Component
public class MyBeanPostProcessor implements InstantiationAwareBeanPostProcessor {

    @Override
    public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
        if ("worker".equals(beanName)) {
            return new Worker();
        } else {
            return null;
        }
    }
}
